using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// Waiter 的摘要说明。
	/// </summary>
	public class Waiter : BaseDAL<WaiterInfo>, IWaiter
	{
		#region 对象实例及构造函数

		public static Waiter Instance
		{
			get
			{
				return new Waiter();
			}
		}
		public Waiter() : base("KF_Waiter","ID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override WaiterInfo DataReaderToEntity(IDataReader dataReader)
		{
			WaiterInfo waiterInfo = new WaiterInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			waiterInfo.ID = reader.GetInt32("ID");
			waiterInfo.WaiterNo = reader.GetString("WaiterNo");
			waiterInfo.Name = reader.GetString("Name");
			waiterInfo.Sex = reader.GetString("Sex");
			waiterInfo.IDNumber = reader.GetString("IDNumber");
			waiterInfo.Telephone = reader.GetString("Telephone");
			waiterInfo.Area = reader.GetString("Area");
			waiterInfo.Grade = reader.GetString("Grade");
			waiterInfo.Note = reader.GetString("Note");
			
			return waiterInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(WaiterInfo obj)
		{
		    WaiterInfo info = obj as WaiterInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("WaiterNo", info.WaiterNo);
 			hash.Add("Name", info.Name);
 			hash.Add("Sex", info.Sex);
 			hash.Add("IDNumber", info.IDNumber);
 			hash.Add("Telephone", info.Telephone);
 			hash.Add("Area", info.Area);
 			hash.Add("Grade", info.Grade);
 			hash.Add("Note", info.Note);
 				
			return hash;
		}

    }
}